using System;
using System.Data;

namespace MushManager.DAL
{

	[AttributeUsage(AttributeTargets.Property)]
	public class BaseFieldAttribute : Attribute
	{
		string columnName;
		public string ColumnName
		{
			get { return columnName; }
			set { columnName = value; }
		}	
		
		public BaseFieldAttribute(string columnName)
		{
			this.columnName = columnName;	
			
		}
	}


	[AttributeUsage(AttributeTargets.Property)]
	public class DataFieldAttribute : BaseFieldAttribute
	{
		public DbType Type { get; set; }
		public int Size { get; set; }
		public Boolean Required { get; set; }

		public DataFieldAttribute(string columnName, DbType type, Boolean required) : this(columnName, type, required, 0) { }
		public DataFieldAttribute(string columnName, DbType type, Boolean required, int size) : base(columnName)
		{
			this.Type = type;
			this.Size = size;
			this.Required = required;
		}
	}
	
	[AttributeUsage(AttributeTargets.Property)]
	public class KeyFieldAttribute : BaseFieldAttribute
	{
		public KeyFieldAttribute(string columnName) : base(columnName)
		{
		
		}
	}
	
	[AttributeUsage(AttributeTargets.Property)]
	public class ForeignKeyFieldAttribute : BaseFieldAttribute
	{
		public string PKTable { get; set; }
		public string PKColumn { get; set; }
		public Boolean Required { get; set; }
		
		public ForeignKeyFieldAttribute(string columnName, string pkTableName, string pkColumnName, bool required) : base(columnName)
		{
			this.PKTable = pkTableName;
			this.PKColumn = pkColumnName;
			this.Required = required;
		}
	}
	
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct)]
	public class DataTableAttribute : Attribute
	{
		public string TableName { get; set; }
		public string UpdateStoredProcedure { get; set; }

		public DataTableAttribute(string tableName) : this(tableName, string.Empty) { }
		public DataTableAttribute(string tableName, string updateStoredProc)
		{
			this.TableName = tableName;
			this.UpdateStoredProcedure = updateStoredProc;
		}
	}
}